package com.risetechnology.krystalkitchen1;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;

import com.risetechnology.common.ButtonBackground;
import com.risetechnology.common.Shared;
import com.risetechnology.utils.SmartSharedPreferrence;

public class ActivityFirstIntro extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// Hide title
		requestWindowFeature(Window.FEATURE_NO_TITLE);

		// Set up layout
		setContentView(R.layout.activity_first_intro);

		// Set contents
		setContents();
	}

	private void setContents() {
		// Introduction text
		TextView textviewIntroTitle = (TextView) findViewById(R.id.tv_intro_title);
		textviewIntroTitle.setTypeface(Shared.font);

		TextView textviewIntroContent = (TextView) findViewById(R.id.tv_intro);
		textviewIntroContent.setTypeface(Shared.font);

		// Text view don't show this again
		TextView textViewDontShow = (TextView) findViewById(R.id.tv_dont_show_this_again);
		textViewDontShow.setTypeface(Shared.font);

		// Check box
		final CheckBox checkboxShowAgain = (CheckBox) findViewById(R.id.checkbox);
		checkboxShowAgain.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				SmartSharedPreferrence.setFirstShowIntro(ActivityFirstIntro.this, !isChecked);
			}
		});


		// Button next
		Button buttonNext = (Button) findViewById(R.id.btn_next);
		ButtonBackground nextButtonBackground = new ButtonBackground(ActivityFirstIntro.this,
				R.drawable.bg_btn_next_pressed, R.drawable.bg_btn_next);
		buttonNext.setBackgroundDrawable(nextButtonBackground);
		buttonNext.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				boolean isShowSecondIntro = SmartSharedPreferrence.getShowSecondIntro(ActivityFirstIntro.this);
				if (isShowSecondIntro) {
					Intent intent = new Intent(ActivityFirstIntro.this, ActivitySecondIntro.class);
					startActivity(intent);
				} else {
					Intent intent = new Intent(ActivityFirstIntro.this, TabsManager.class);
					startActivity(intent);
					finish();
				}

				finish();
			}
		});

		// Disable introduction page next time
		// SmartSharedPreferrence.setFirstShowIntro(ActivityFirstIntro.this, false);
	}

}
